package router

import (
	"ChdChat-Gin/api"
	"ChdChat-Gin/middleware"
	"github.com/gin-gonic/gin"
)

func userGroup(subRouter *gin.RouterGroup) {
	authRouter := subRouter.Group("/v1.0")
	{
		// authentications
		authRouter.PUT("/authentications", api.Login)
		authRouter.POST("/authentications", api.Register)
		authRouter.DELETE("/authentications", middleware.Authenticate(), api.Logout)
	}
	contactRouter := subRouter.Group("/v1.0")
	{
		// contacts
		contactRouter.GET("/contacts", middleware.Authenticate(), api.FetchContacts)
		contactRouter.POST("/contacts", middleware.Authenticate(), api.AddContact)
		contactRouter.DELETE("/contacts", middleware.Authenticate(), api.DeleteContact)
		// notices
		contactRouter.GET("/contact-notices", middleware.Authenticate(), api.FetchContactNotices)
		contactRouter.PUT("/contact-notices", middleware.Authenticate(), api.HandleNotice)
		// List of contacts that can be added
		contactRouter.GET("/user-list", middleware.Authenticate(), api.FetchUserList)
		contactRouter.GET("/group-list", middleware.Authenticate(), api.FetchGroupList)
	}
	userInfoRouter := subRouter.Group("/v1.0")
	{
		// user-infos
		userInfoRouter.PUT("/user-infos", middleware.Authenticate(), api.UpdateUserInfo)
		// avatars
		userInfoRouter.GET("/avatars", middleware.Authenticate(), api.FetchAvatarSrc)
		userInfoRouter.POST("/avatars", middleware.Authenticate(), api.UploadAvatar)
	}
}
